package com.pet.system.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 异常枚举
 * 
 * @author lh
 * @email 
 * @time 2013-9-17 下午12:37:42
 * 不要修改异常码
 */
public enum MessageUtill {
	/** ------系统异常------ */
	ReturnSUCESS(0, "转单成功！"),
	/** ------系统异常------ */
	SystemError(19999, "系统繁忙，请稍后再试，谢谢!"),

	/** ------参数异常------ */
	ParamNull(19001, "参数不可为空!"),
	/***/
	ParamTypeNotMatch(19002, "参数类型不匹配!"),
	/***/
	ParamNotCorrect(19003, "参数不正确!"),
	/***/
	NetNotAble(19004, "回调接口访问失败!"),
	
	/***/
	FetchResultNotCorrect(19005, "获取交易信息失败！"),
	/***/
	ResultNotCorrect(19006, "商品信息获取错误！"),
	/***/
	FetchAPIResultNotCorrect(19007, "访问api接口失败！"),
	/***/
	OrderExist(19008, "该订单发布过！"),
	/***/
	OutputResultNull(19009, "结果不可为空!"),
	/***/
	SignNotCorrect(19010, "签名不正确!"),
	/***/
	OrderCountNotCorrect(19011, "商品信息不正确!"),
	/***/
	AccountNotExist(19012, "该手机号没有在花千束转单平台上注册。"),
	/***/
	SignFALSE(19010, "签名不正确!"),
	/***/
	MobileExist(19013, "该手机号是花千束转单平台用户。");


	public int code;
	public String comments;

	MessageUtill(int code, String comments) {
		this.code = code;
		this.comments = comments;
	}

	private static Map<Integer, MessageUtill> map = new HashMap<Integer, MessageUtill>();

	public static MessageUtill get(final int code) {
		MessageUtill e = map.get(code);
		if (e == null) {
			throw new IllegalArgumentException(String.format("%s没有对应值,code=%s", MessageUtill.class.getName(), code));
		}
		return e;
	}

	public static SystemException format(MessageUtill e, String... s) {
		return new SystemException(e.code, String.format(e.comments, (Object[])s));
	}

	public static class SystemException {
		public int code;
		public String comments;

		public SystemException(int code, String comments) {
			this.code = code;
			this.comments = comments;
		}

		public int getCode() {
			return code;
		}

		public void setCode(int code) {
			this.code = code;
		}

		public String getComments() {
			return comments;
		}

		public void setComments(String comments) {
			this.comments = comments;
		}
	}
}

